home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / mildred.lha / lha / SineExample.lha / SineExample2.ascii < prev    next >
Text File  |  1999-03-23  |  4KB  |  114 lines

  1. ;Wavey Logo Mildred Library Example.
  2. ;
  3. ;Programmed by : Mikkel Loekke, aka. FlameDuck.
  4. ;
  5. ;Please read the README file.
  6. ;
  7. ;Modified by Paul West to use OffsetList with MScroll and lookup tables
  8.  
  9. WBStartup
  10. NoCli
  11.  
  12. DEFTYPE.l
  13.  
  14. degrad.q = Pi/180                   ; Since the computer works in
  15.                                     ; radians, we need this value
  16.                                     ; to convert our angle to radians.
  17.                                     ; (Or something) :o)
  18.  
  19. Dim Lookup.w(750)                   ; Setup our sine lookup table.
  20. Dim Lookup2.w(750)
  21. For i=0 To 750                      ; Array needs to be .w. If you use .q it will not work properly
  22.   Lookup(i)=Sin((i)*degrad*3)*30
  23.   Lookup2(i)=Sin((i)*degrad*2)*20
  24. Next
  25.  
  26. NEWTYPE.OffsetList
  27.   LineWidth.w
  28.   X1Offset.w
  29.   X2Offset.w
  30.   SourceModuloOffset.w
  31. End NEWTYPE
  32. Dim rows.OffsetList(570)
  33. rows(0)\LineWidth=320,0,Lookup(0),0
  34. For y=1 To 570                            ; Do the sine wavey bits.
  35.   rows(y)\LineWidth=320
  36.   rows(y)\X1Offset=Lookup(y)-Lookup(y-1)
  37.   rows(y)\X2Offset=0
  38.   rows(y)\SourceModuloOffset=0
  39. Next
  40.  
  41. MCPU Processor                      ; Tell Mildred which CPU it should use.
  42. Mc2pCPUmode Processor               ; Tell Mildred which CPU it should us for c2p.
  43.  
  44. MReserveBitmaps 2                   ; Tell Mildred that we're going to use 2 chunky bitmaps.
  45. MReservec2pWindows 1                ; Tell it we only need one c2p display.
  46.  
  47. .initgraphics
  48. MCludgeBitmap 0,320,210,?inclogo    ; Go fetch our original chunky image.
  49. MBitmap 1,320,250                   ; This will contain our chunky buffer.
  50.  
  51. Mc2pWindow 0,320,210                ; Setup structures for c2p conversions.
  52.  
  53. InitBank 0,320*210,$10002           ; Get some free CHIP memory.
  54. CludgeBitMap 0,320,210,8,Bank(0)    ; And make it a planar bitmap.
  55.  
  56. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  57. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  58. scrtaglst(0)\ti_Data = 0          ; want. As you can see, it's
  59. scrtaglst(1)\ti_Tag = #SA_Depth     ; rather non-standard.
  60. scrtaglst(1)\ti_Data = 8            ; it doesn't have to be, it's
  61. scrtaglst(2)\ti_Tag = #SA_Width     ; just that this routine needs
  62. scrtaglst(2)\ti_Data = 320          ; a larger screen to avoid
  63. scrtaglst(3)\ti_Tag = #SA_Height    ; clipping.
  64. scrtaglst(3)\ti_Data = 210
  65. scrtaglst(4)\ti_Tag = #SA_BitMap
  66. scrtaglst(4)\ti_Data = Addr BitMap (0)
  67. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  68. scrtaglst(5)\ti_Data = 0
  69. scrtaglst(6)\ti_Tag = #SA_Draggable
  70. scrtaglst(6)\ti_Data = 0
  71. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  72.  
  73.  
  74. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
  75.  
  76. DecodePalette 0,?incpal             ; Get our IncBin'ed palette info.
  77.  
  78. ShowPalette 0                       ; Attach our palette to the screen.
  79.  
  80. MUseBitmap 1                        ; Tell Mildred to use our main
  81.                                     ; chunky buffer (just in case)
  82.  
  83. Repeat                              ; Repeat our mainloop ....
  84.   Mc2p Bank(0)                      ; Convert our chunky buffer to
  85.                                     ; our planar bitmap.
  86.  
  87.   Temp.w=rows(deg)\X1Offset
  88.   rows(deg)\X1Offset=Lookup(deg)
  89.   MScroll 0,0,320,210,0,0,0,&rows(deg) ; Tell Mildred how to move our graphics arround, and where to put them.
  90.   rows(deg)\X1Offset=Temp
  91.  
  92. For x=0 To 319 Step 2
  93.   MScroll x,20+Lookup2(deg+x),2,210,x,0
  94. Next x
  95.  
  96.   deg+1                             ; do another degree on the sinewave.
  97.   If deg=360 Then deg=0
  98.  
  99. Until RawStatus($45)                ; .... Until we press Escape.
  100.  
  101. End                                 ; End our nice program.
  102.  
  103.  
  104. Even4                               ; put following data on an even address. Minor speed increase.
  105. .incpal
  106. IncBin "IntroLogo.PAL" ; Include our palette information in the binary.
  107.  
  108. Even4                               ; Same as last time :o)
  109. Ds.l 16
  110. .inclogo
  111. IncBin "IntroLogo.CNK" ; Include our chunky logo.
  112. Ds.l 16
  113.  
  114.